package log

import (
	"fmt"
	"github.com/beego/beego/v2/core/logs"
	beego "github.com/beego/beego/v2/server/web"
	"os"
)


var (
	Logger     = logs.NewLogger()

	logLevel,_ = beego.AppConfig.Int("logleavel")
	maxLines,_ = beego.AppConfig.Int("logmaxlines")
	maxDays,_  = beego.AppConfig.Int("logmaxdays")
)


func init() {
	if _, err := os.Stat("logs"); err != nil {
		os.Mkdir("logs", os.ModePerm)
	}

	LogsConf := fmt.Sprintf(`{"filename":"logs/easybolg.log","level":%v,"maxlines":%v,"maxsize":0,"daily":true,"maxdays":%v}`, logLevel, maxLines, maxDays)
	Logger.SetLogger(logs.AdapterFile, LogsConf)
	Logger.SetLogger("console")
	Logger.EnableFuncCallDepth(true) //是否显示文件和行号
}